<?php


namespace App\Http\Controllers\Api;

use App\Model\Rebate;
use Illuminate\Http\Request;

class RebateController extends BaseController
{
    protected $rebateModel;

    /**
     * @param Request $request
     */
    public function __construct(Request $request)
    {
        parent::__construct($request);
        $this->rebateModel = new Rebate();
    }

    /**
     * 返利统计
     */
    public function rebateList(Request $request){
        $page = $request->get('page',1);
        $limit = $request->get('limit',10);
        $user_id = $request->get('user_id',0);
        $start_time = $request->get('created_st',0);
        $end_time = $request->get('created_ed',0);
        //根据搜索条件获取统计数据
        $total = $this->rebateModel->getSearchAll($user_id, $start_time, $end_time);
        //正常分页数据
        $res = $this->rebateModel->getRebateList($page, $limit, $user_id, $start_time, $end_time);
        $data = $res;
        //最终数据
        $data['total_table'] = $total;
        return $this->toJson(self::SUCCESS, $data);
    }
}